var DAO=require('./DAO')
var productDAO={
    getProductList:function(typeId,callback){
        DAO('select * from product  where productTypeId=?',[typeId],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductDetail:function(productId,callback){
        DAO('select * from product where productId=?',[productId],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductFestival:function(festival,callback){       
        DAO("select * from product where festival like '%"+festival+"%'",[],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductPinzhong:function(pinzhong,callback){    
        DAO("select * from product where kind like '%"+pinzhong+"%'",[],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductYongtu:function(yongtu,callback){     
        DAO("select * from product where yongtu like '%"+yongtu+"%'",[],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductCailiao:function(cailiao,callback){
        DAO("select * from product where material like '%"+cailiao+"%'",[],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductGao:function(gao,callback){
        DAO("select * from product where productTypeId=? order by price  desc",[gao],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductDi:function(di,callback){
        DAO("select * from product where productTypeId=? order by  price",[di],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    },
    getProductTheme:function(themeId,callback){
        DAO('select * from product  where themeId=?',[themeId],function(err,results){
            if(err){
                callback(err,null)
            }else{
                callback(null,results)
            }
        })
    }

}

module.exports=productDAO